"""
 Copyright 2009 White Waters Software
 White Waters Software Copyright 2007 Jason White

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 CONTACT: whitewaterssoftwareinfo@gmail.com
 
 Medina , Ohio , United States Of America , Solar System , Milky Way Galaxy , The Universe : as I know it
 """
import pygame
import objects
import music
import defs
import sys
import os
#init all
pygame.init()
pygame.display.init()

screen=pygame.display.set_mode((800,600),pygame.FULLSCREEN)

background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((0, 0, 30))

pygame.mouse.set_visible(0)
#objects
objects.index=[]
ind=objects.player()
objects.play=ind
play=ind
objects.index.append(ind)
ind.ind=ind
#loop
clock = pygame.time.Clock()
i=0
while 1:
    score=play.score
    if not pygame.mixer.music.get_busy():
        music.music()
    clock.tick(40)
    background.fill((0,0,30))
    allsprites = pygame.sprite.RenderPlain(objects.index)
    allsprites.update()
    allsprites.draw(background)
    #HUD

    image=pygame.Surface((130,600))
    image.fill((40, 40, 60))
    pos = image.get_rect(topleft=(670,0))
    background.blit(image, pos)

    image , pos =defs.load_image('small Nvade logo.gif',-1)
    pos.topleft = (686,0)
    background.blit(image, pos)

    font = pygame.font.Font(None, 18)
    text = font.render("Score: "+str(score), 1, (255, 255, 255))
    textpos = text.get_rect(topleft=(673,60))
    background.blit(text, textpos)

    font = pygame.font.Font(None, 18)
    text = font.render("Lives: "+str(play.lives), 1, (255, 255, 255))
    textpos = text.get_rect(topleft=(674,80))
    background.blit(text, textpos)
    
    if i < 300:
        i+=1
        img,pos=defs.load_image("Nvade logo.gif",-1)
        pos.center = (355,300)
        background.blit(img, pos)
    
    #blit
    screen.blit(background, (0, 0))
    pygame.display.flip()

    key=pygame.key.get_pressed()
    if key[pygame.K_ESCAPE]:
            defs.exit_game()                    
    for event in pygame.event.get():
            if event.type == pygame.QUIT:
                defs.exit_game()




        




